package com.bigShen.spring.official;

import com.bigShen.spring.springBean.entity.UserInfo;
import com.bigShen.spring.springBean.service.UserInfoService;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
 * @author : lei.shen
 * @date : 2019/1/18
 */
public class DifficultApplicationContext {

    public static void main(String[] args) {
        // 定位  指定resource
        // 载入  将xml源文件解析成BeanDefinition,记录静态数据
        // 注册  map保存bean

        // 设置资源加载器和资源定位
        String source = "applicationContext.xml";
        // new context 构造器父类创建时, 指定 资源加载器
        FileSystemXmlApplicationContext applicationContext =
                new FileSystemXmlApplicationContext(source, "con1.xml", "con2.xml");

        UserInfo userInfo = (UserInfo) applicationContext.getBean("userT");
        System.out.println(userInfo);

        UserInfoService userInfoService = (UserInfoService) applicationContext.getBean(UserInfoService.class);
        System.out.println(userInfoService.selectUserByName("na"));


        //new XmlBeanDefinitionReader(new DefaultListableBeanFactory())
        //        .loadBeanDefinitions(new ClassPathResource("applicationContext.xml"));

    }

}
